import pyaudio, sys
from numpy import fromstring, short
from scipy import fft

# sound setting ###########
chunk = 128
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 22050
RECORD_SECONDS =60

p = pyaudio.PyAudio()
stream = p.open(format = FORMAT,
                channels = CHANNELS, 
                rate = RATE, 
                input = True,
                output = False)



print "* recording"
while 1:
    val = 0
    data = stream.read(chunk)
    audio = fromstring(data, dtype = short)
    normalized = audio / 32768.0
    print abs(normalized)
